-----------------------------------------------------------------------------------------
-- filename : layer.lua
-- description : Layering script for game screen
-----------------------------------------------------------------------------------------

-- local variables
local layer = {}
layer.layerTable = {}
layer.BACKGROUND = 0
layer.BOARD = 1
layer.DIR = 2
layer.PION = 3
layer.PION_1 = 0
layer.PION_2 = 1
layer.PION_3 = 2
layer.PION_4 = 3
layer.PION_5 = 4
layer.PION_6 = 5
layer.PION_7 = 6
layer.HUD = 13
layer.CONF = 14

function layer.generateLayerGroup( group, indexNumber)
	for i = 0, indexNumber-1 do
		layer.layerTable[i] = display.newGroup()
		group:insert(layer.layerTable[i])
		print("Layer")
	end
end

function layer.generateLayer( indexNumber )
	for i = 0, indexNumber-1 do
		layer.layerTable[i] = display.newGroup()
		print("Layer")
	end
end

function layer.insertImage(indexLayer,image)
	layer.layerTable[indexLayer]:insert(image)
end

function layer.insertImageByIndex(indexLayer, index ,image)
	print("layer : "..indexLayer+index)
	layer.layerTable[indexLayer+index]:insert(image)
end

function layer.createImage( indexLayer,imageName,left,top,width,height )
	local img = display.newImageRect( layer.layerTable[indexLayer], imageName, width, height, true )
	img:setReferencePoint(display.TopLeftReferencePoint)
	img.x = left
	img.y = top
	return img
end

function layer.clean(indexLayer) 
	print(layer.layerTable[indexLayer].numChildren)
	for i=layer.layerTable[indexLayer].numChildren,1,-1 do
		layer.layerTable[indexLayer][i].parent:remove(layer.layerTable[indexLayer][i])
	end
	print(layer.layerTable[indexLayer].numChildren)
end

--layer.generateLayer(6)

return layer